using System.Collections.Generic;

namespace PathX
{
    public sealed class PathNodeComparer : IComparer<IPathNode>
    {
        public int Compare(IPathNode x, IPathNode y)
        {
            int compareCost = y.f.CompareTo(x.f);

            //tie breaker simply uses h, preferring a smaller h will prefer cells closer to the goal
            if (compareCost == 0)
            {
                return y.h.CompareTo(x.h);
            }

            return compareCost;
        }
    }
}